<template>
	<view>
		<view class="status_bar">
			<fui-status-bar background="#FFF" isFixed></fui-status-bar>
		</view>
		<fui-landscape :show="SigninPop" maskClosable @close="closePopup">
			<view class="SigninPop">
				<view class="SigninPopBox">
					<view style="font-size:50rpx;font-weight:bold">签到成功</view>
					<view class="SigninAddCoin">
						<image :src="baseUrl + 'icon/goldcoin.png'" style="width:50rpx;height:50rpx;"></image>
						<text style="margin-left:40rpx;font-size:36rpx;"> + 1</text>
					</view>
					<view style="font-size:28rpx;margin-top:40rpx;">邀请好友可获得更多金币</view>
				</view>
				<view style="margin-top:40rpx;">
					<button class="InviteBtn" @click="goToInvite">去邀请</button>
				</view>
			</view>
		</fui-landscape>
		<view class="indexTab">
			<view class="citySelect" @click="selectCityBtn">{{ MyCity.text }}</view>
			<view class="index_menu">
				<fui-tabs :tabs="pageTabs" :current="tabIndex" isSlider selectedColor="#000" sliderBackground="#FFDD00"
					@change="changeTabs"></fui-tabs>
			</view>
		</view>
		<swiper :current="tabIndex" :duration="300" @change="tabChange" :style="{height:height+'px'}">
			<!-- 通告列表 -->
			<swiper-item class="fui-swiper__item">
				<scroll-view scroll-y :show-scrollbar="false" :style="{height:height+'px'}"
					@scrolltolower="onPullUpLoading(1)" :refresher-enabled="true" :refresher-triggered="isRefreshList"
					@refresherrefresh="onRefresherrefresh(1)">
					<view class="indexfTab flexbc">
						<view class="indexfTab_left">
							<fui-tabs :tabs="subPageTabs" :current="AsubTabIndex" alignLeft isSlider height="45"
								selectedColor="#000" sliderHeight="40" padding="6" sliderBackground="#FFDD00"
								sliderRadius="10" @change="changeSubTab($event,'A')"></fui-tabs>
						</view>
						<view style="width:120rpx;display:flex;">
							<view class="signinBtn" style="background-color: #FFDD00;" @click="handleSignin"
								v-if="isSignin == 0">签</view>
							<view class="signinBtn" style="background-color: #e5e5e5;color: #797979;" v-else>签</view>
							<view class="indexfTab_search" style="margin-left:20rpx" @click="openSearch(1)">筛选</view>
						</view>
					</view>

					<view v-if="AsubTabIndex == 0">
						<view class="indexAdBox">
							<fui-swiper-dot :items="AdList" :current="current">
								<swiper class="fui-banner__wrap" circular :indicator-dots="false" autoplay
									:interval="4000" :duration="150">
									<swiper-item v-for="(item,index) in AdList" :key="index" @click="gotoAdUrl(item)">
										<view class="fui-banner__item"
											:style="{backgroundImage:'url('+item.AdPicUrl+')',backgroundSize:'cover'}">
										</view>
									</swiper-item>
								</swiper>
							</fui-swiper-dot>
						</view>

						<index-menu @goMakeMoka="goMakeMoka" @switchTab="switchTab"
							@gotoMsgPage="gotoMsgPage"></index-menu>

						<view class="indexBoxs">
							<view v-if="NoticeListA.length != 0">
								<index-notice :NoticeList="NoticeListA"></index-notice>
								<uni-load-more :status="more"></uni-load-more>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>

					<view v-if="AsubTabIndex == 1">
						<view class="indexBoxs">
							<view v-if="NoticeListB.length != 0">
								<index-notice :NoticeList="NoticeListB"></index-notice>
								<uni-load-more :status="more"></uni-load-more>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>
					<view v-if="AsubTabIndex == 2">
						<view class="indexBoxs">
							<view v-if="NoticeListC.length != 0">
								<index-notice :NoticeList="NoticeListC"></index-notice>
								<uni-load-more :status="more"></uni-load-more>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
			<!-- 约单列表 -->
			<swiper-item class="fui-swiper__item">
				<scroll-view scroll-y :style="{height:height+'px'}" :show-scrollbar="false"
					@scrolltolower="onPullUpLoading(2)" :refresher-enabled="true" :refresher-triggered="isRefreshList"
					@refresherrefresh="onRefresherrefresh(2)">
					<view class="indexfTab flexbc">
						<view class="indexfTab_left">
							<fui-tabs :tabs="subPageTabs" :current="BsubTabIndex" alignLeft isSlider height="45"
								selectedColor="#000" sliderHeight="40" padding="6" sliderBackground="#FFDD00"
								sliderRadius="10" @change="changeSubTab($event,'B')"></fui-tabs>
						</view>
						<view class="indexfTab_search" @click="openSearch(2)">筛选</view>
					</view>
					<view v-if="BsubTabIndex == 0">
						<view class="indexBoxs">
							<view v-if="ReservationOrderListA.length != 0">
								<index-reservationorder
									:ReservationOrderList="ReservationOrderListA"></index-reservationorder>
								<uni-load-more :status="more"></uni-load-more>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>
					<view v-if="BsubTabIndex == 1">
						<view class="indexBoxs">
							<view v-if="ReservationOrderListB.length != 0">
								<index-reservationorder
									:ReservationOrderList="ReservationOrderListB"></index-reservationorder>
								<uni-load-more :status="more"></uni-load-more>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>
					<view v-if="BsubTabIndex == 2">
						<view class="indexBoxs">
							<view v-if="ReservationOrderListC.length != 0">
								<index-reservationorder
									:ReservationOrderList="ReservationOrderListC"></index-reservationorder>
								<uni-load-more :status="more"></uni-load-more>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
			<!-- 作品列表 -->
			<swiper-item class="fui-swiper__item">
				<scroll-view scroll-y :style="{height:height+'px'}" :show-scrollbar="false"
					@scrolltolower="onPullUpLoading(3)" :refresher-enabled="true" :refresher-triggered="isRefreshList"
					@refresherrefresh="onRefresherrefresh(3)">
					<view class="indexfTab flexbc">
						<view class="indexfTab_left">
							<fui-tabs :tabs="subPageTabs" :current="CsubTabIndex" alignLeft isSlider height="45"
								selectedColor="#000" sliderHeight="40" padding="6" sliderBackground="#FFDD00"
								sliderRadius="10" @change="changeSubTab($event,'C')"></fui-tabs>
						</view>
						<view class="indexfTab_search" @click="openSearch(3)">筛选</view>
					</view>
					<view v-if="CsubTabIndex == 0">
						<view class="indexBoxs">
							<view class="waterfall" v-if="WorksListA.length != 0">
								<zero-waterfall :list="WorksListA" :oneRendering="oneRendering"
									:isChangeTab="isChangeTab"></zero-waterfall>
								<view class="" style="float: left;width:100%;">
									<uni-load-more :status="more"></uni-load-more>
								</view>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>
					<view v-if="CsubTabIndex == 1">
						<view class="indexBoxs">
							<view v-if="WorksListB.length != 0" class="waterfall">
								<zero-waterfall :list="WorksListB" :oneRendering="oneRendering"
									:isChangeTab="isChangeTab"></zero-waterfall>
								<view class="" style="float: left;width:100%;">
									<uni-load-more :status="more"></uni-load-more>
								</view>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>
					<view v-if="CsubTabIndex == 2">
						<view class="indexBoxs">
							<view v-if="WorksListC.length != 0" class="waterfall">
								<zero-waterfall :list="WorksListC" :oneRendering="oneRendering"
									:isChangeTab="isChangeTab"></zero-waterfall>
								<view class="" style="float: left;width:100%;">
									<uni-load-more :status="more"></uni-load-more>
								</view>
							</view>
							<view
								style="display: flex;flex-direction: row;justify-content: center;align-items: center;margin-top: 50rpx;"
								v-else>
								<view class="">
									<image :src="baseUrl + 'icon/null.png'" mode="widthFix"></image>
									<view class="" style="text-align: center;">
										暂无信息
									</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>

		</swiper>

		<index-search ref="searchPopup" :MyCity="MyCity" :Labels="Labels" :searchSex="searchSex"
			:chargeModes="chargeModes" @confirmSearch="onConfirmSearch" @closeSearch="onCloseSearch"
			:isHome="isHome"></index-search>
		<fui-modal :buttons="buttons" width="600" :descr="descr" :show="isVipCheck" @click="HandleCheckVip">
			<view class="fui-icon__close" @tap="onCancel">
				<fui-icon name="close" color="#B2B2B2" :size="48"></fui-icon>
			</view>
		</fui-modal>
	</view>
</template>

<script>
	import cityListData from "@/script/citylist.js"
	import IndexMenu from "./component/index-menu"
	import IndexNotice from "./component/index-notice"
	import IndexReservationorder from "./component/index-reservationorder"
	import IndexWorks from "./component/index-works"
	import IndexSearch from "./component/index-search"

	import ztAuthLabel from "@/components/authLabel.vue";
	import ZtPersonalityLabel from "@/components/personalityLabel.vue";
	import ZtHeadWear from "@/components/headwear.vue"

	export default {
		filters: {
			formatPrice(price) {
				if (price > 10000) {
					return price / 10000 + 'w';
				} else if (price > 1000) {
					return price / 1000 + 'k'
				} else {
					return parseInt(price, 10);
				}
			}
		},
		components: {
			IndexMenu,
			IndexNotice,
			IndexReservationorder,
			IndexWorks,
			IndexSearch,
			ztAuthLabel,
			ZtPersonalityLabel,
			ZtHeadWear
		},
		data() {
			return {
				// 判断是不是首页
				isHome: 0,

				oneRendering: false,
				inviter: 0,
				height: 0,
				CityList: [],
				formData: {
					cityJson: {},
					city: '全部',
					cityCode: []
				},
				searchSex: [{
						sex: -1,
						sexName: '全部'
					},
					{
						sex: 0,
						sexName: '女'
					},
					{
						sex: 1,
						sexName: '男'
					}
				],
				currSearchSex: -1,
				chargeModes: [{
						LabelID: -1,
						LabelName: '全部'
					},
					{
						LabelID: 0,
						LabelName: '接受互勉'
					},
					{
						LabelID: 1,
						LabelName: '无费置换'
					},
					{
						LabelID: 2,
						LabelName: '费用协商'
					},
					{
						LabelID: 3,
						LabelName: '需要收费'
					}
				],
				MyCity: {
					text: '选择地区'
				},
				pageTabs: [{
						name: '通告'
					},
					{
						name: '约单'
					},
					{
						name: '作品'
					}
				],
				tabIndex: 0,
				subPageTabs: [{
						name: '推荐'
					},
					{
						name: '最新'
					},
					{
						name: '同城'
					}
				],

				// index
				AsubTabIndex: 0,
				BsubTabIndex: 0,
				CsubTabIndex: 0,

				// 列表
				AdList: [],
				Labels: [],
				NoticeListA: [],
				NoticeListB: [],
				NoticeListC: [],
				ReservationOrderListA: [],
				ReservationOrderListB: [],
				ReservationOrderListC: [],
				WorksListA: [],
				WorksListB: [],
				WorksListC: [],

				isLogin: false,
				LoginInfo: {
					isLogin: 0,
					UserInfo: {}
				},
				isVipCheck: false,
				buttons: [{
						//按钮文本，必选
						text: '申请【颜值美女】',
						//按钮文本颜色，可选
						color: '#000',
						//按钮背景颜色，可选
						background: '#FFDD00',
						//是否为镂空按钮，即背景色为透明，可选
						plain: false
					},
					{
						//按钮文本，必选
						text: '开通VIP会员',
						//按钮文本颜色，可选
						color: '#fff',
						//按钮背景颜色，可选
						background: '#FF6600',
						//是否为镂空按钮，即背景色为透明，可选
						plain: false
					}
				],
				descr: 'VIP聊天室仅VIP用户\r\n或有【颜值美女】标识的艺人可进',
				SigninPop: false,
				page: 1,
				more: '',
				SearchParams: {},
				isSignin: 0,

				baseUrl: '',
				// 是否切换tab
				isChangeTab: false,

				isRefreshList: false
			}
		},
		onShow() {
			if (uni.getStorageSync("isLogin")) {
				// console.log('getStorageSyncTrue', uni.getStorageSync("isLogin"))
				this.LoginInfo = uni.getStorageSync("isLogin");
				this.onGetUserLogin();
			} else {
				this.isLogin = false
			}

			// 本地如果存储 page 使用本地数据
			if (uni.getStorageSync('page')) {
				this.page = uni.getStorageSync('page');
			} else {
				this.page = 1;
			}


			let time = 80
			// #ifdef H5
			time = 200
			// #endif
			setTimeout(() => {
				this.height = uni.getSystemInfoSync().windowHeight - uni.upx2px(200);
				// #ifdef MP
				// this.getStatus().then((res) => {})
				// #endif
			}, time)

			if (uni.getStorageSync("MyCity")) {
				this.MyCity = uni.getStorageSync("MyCity")
				// this.onGetList(0, 0);

				// console.log("执行")
			} else {
				// console.log("执行getLocation")
				this.CityList = cityListData.cityListData

				try {
					this.getLocation();
				} catch (err) {
					// 如果当前版本较低采用
					// console.log(err)
					if (this.MyCity.text = '选择地区') {
						uni.showModal({
							title: '请选择地址！',
							content: '由于当前版本较低，无法享有平台大部分功能，需要您手动选择地址！',
							showCancel: false,
							success: res => {
								if (res.confirm) {
									uni.navigateTo({
										url: '/pages/index/selectCity'
									})
								}
							}
						})
					}
				}
			};

		},
		onTabItemTap(e) {
			this.page = 1
			this.onGetList(0, 0);
			console.log("e", e)
		},
		onLoad(options) {
			uni.setStorageSync('page', 1)
			this.baseUrl = this.$baseUrl;
			if (uni.getStorageSync('indexObj')) {
				// console.log("uni.getStorageSync('indexObj')" , uni.getStorageSync('indexObj'))
			}
			let inviter = options.inviter
			if (inviter) {
				uni.setStorageSync("inviter", inviter);
			} else {
				uni.setStorageSync("inviter", 0);
			}
			this.onGetList(0, 0);
			this.inviter = uni.getStorageSync("inviter")
		},
		// 下拉刷新
		// onPullDownRefresh () {
		// 	// 清空筛选数据
		// 	this.SearchParams = {};
		// 	// 一级tab
		// 	switch (this.tabIndex) {
		// 		// 二级tab
		// 		case 0:
		// 			this.loadNoticeDataOne(this.AsubTabIndex)
		// 			break;
		// 		case 1:
		// 			this.loadResOrderDataOne(this.BsubTabIndex)
		// 			break;
		// 		case 2:
		// 			this.loadWorksDataOne(this.CsubTabIndex)
		// 			break;
		// 	}
		// 	// 停止当前页面下拉刷新
		// 	uni.stopPullDownRefresh();
		// },
		onShareAppMessage({}) {
			return {
				title: "美模通告邀请您入驻",
				path: "/pages/index/index?inviter=" + this.LoginInfo.UserID,
				imageUrl: "https://api.meimo.comdns.cn/public/commshare.jpg"
			}
		},
		onShareTimeline({}) {
			return {
				title: "美模通告邀请您入驻",
				path: "/pages/index/index?inviter=" + this.LoginInfo.UserID,
				imageUrl: "https://api.meimo.comdns.cn/public/commshare.jpg"
			}
		},
		methods: {
			// 下拉刷新
			onRefresherrefresh(listType) {
				// listType  通告列表 1；约单列表 2；作品列表 3
				this.isRefreshList = true;
				this.page = 1
				// 清空筛选数据
				this.SearchParams = {};
				// 一级tab
				switch (this.tabIndex) {
					// 二级tab
					case 0:
						if (listType == 1) this.loadNoticeDataOne(this.AsubTabIndex)
						break;
					case 1:
						if (listType == 2) this.loadResOrderDataOne(this.BsubTabIndex)
						break;
					case 2:
						if (listType == 3) this.loadWorksDataOne(this.CsubTabIndex)
						break;
				}
			},
			// 清除
			onCloseSearch() {
				if (this.tabIndex == 0) this.loadNoticeDataOne(this.AsubTabIndex)
				if (this.tabIndex == 1) this.loadResOrderDataOne(this.BsubTabIndex)
				if (this.tabIndex == 2) this.loadWorksDataOne(this.CsubTabIndex)
			},
			onConfirmSearch(SearchParams) {
				this.SearchParams = SearchParams;
				// console.log('SearchParams', SearchParams)
				this.page = 1;
				if (this.tabIndex == 0) {
					this.NoticeListA = [];
					this.NoticeListB = [];
					this.NoticeListC = [];
					this.loadNoticeData(this.AsubTabIndex, SearchParams)
				}
				if (this.tabIndex == 1) {
					this.ReservationOrderListA = [];
					this.ReservationOrderListB = [];
					this.ReservationOrderListC = [];
					this.loadResOrderData(this.BsubTabIndex, SearchParams)
				}
				if (this.tabIndex == 2) {
					this.WorksListA = [];
					this.WorksListB = [];
					this.WorksListC = [];
					this.loadWorksData(this.CsubTabIndex, SearchParams)
				}
			},
			// 通告筛选
			noticeSearch(params) {
				this.$httpost('/home/SearchNoticeList', {
					SearchRoleID: params.selectID,
					City: Array.isArray(params.cityCode) ? params.cityCode[0] : params.cityCode,
					page: 1,
					indexType: this.AsubTabIndex
				}).then(res => {
					if (res.code == 200) {
						if (this.AsubTabIndex == 0) this.NoticeListA = res.data.list;
						if (this.AsubTabIndex == 1) this.NoticeListB = res.data.list;
						if (this.AsubTabIndex == 2) this.NoticeListC = res.data.list;
					}
					// console.log('筛选通告功能', res)
				})
			},

			// 约单筛选
			reservationOrderSearch(params) {
				this.$httpost('/home/SearchReservationOrderList', {
					SearchRoleID: params.reservationOrderObj, // 约单对象ID
					City: Array.isArray(params.cityCode) ? params.cityCode[0] : params.cityCode, // 地址
					page: 1,
					indexType: this.BsubTabIndex,
					SearchPriceType: params.SearchPriceType, // 收费模式
					SearchSex: params.searchSex // 性别
				}).then(res => {
					if (res.code == 200) {
						if (this.BsubTabIndex == 0) this.ReservationOrderListA = res.data.list;
						if (this.BsubTabIndex == 1) this.ReservationOrderListB = res.data.list;
						if (this.BsubTabIndex == 2) this.ReservationOrderListC = res.data.list;
					}
					// console.log('筛选约单功能', res)
				})
			},

			// 作品筛选
			workerSearch(params) {
				this.$httpost('/home/SearchWorksList', {
					SearchRoleID: params.selectID, // 发布人ID
					City: Array.isArray(params.cityCode) ? params.cityCode[0] : params.cityCode, // 地址
					page: 1,
					indexType: this.BsubTabIndex,
					SearchSex: params.searchSex // 性别
				}).then(res => {
					if (res.code == 200) {
						if (this.BsubTabIndex == 0) this.WorksListA = res.data.list;
						if (this.BsubTabIndex == 1) this.WorksListB = res.data.list;
						if (this.BsubTabIndex == 2) this.WorksListC = res.data.list;
					}
					// console.log('筛选约单功能', res)
				})
			},

			// 上拉加载
			onPullUpLoading(oneTabIndex) {
				this.page += 1;
				uni.setStorageSync('page', this.page)
				// 一级tab
				switch (this.tabIndex) {
					// 二级tab
					case 0:
						this.loadNoticeData(this.AsubTabIndex, this.SearchParams)
						break;
					case 1:
						this.loadResOrderData(this.BsubTabIndex, this.SearchParams)
						break;
					case 2:
						this.loadWorksData(this.CsubTabIndex, this.SearchParams)
						break;
				}

				// console.log('到底了~')
			},
			goToInvite() {
				this.$common.goNavPage('/myPages/pages/invite')
			},
			closePopup() {
				this.SigninPop = false
			},
			handleSignin() {
				if (uni.getStorageSync("isLogin")) {
					this.$httpost('/UserAction/Signin', {}).then(res => {
						// console.log('signin', res);
						if (res.code == 200) {
							if (res.data.signinState === 1) {
								this.SigninPop = true
								this.isSignin = 1;
							} else {
								uni.showToast({
									title: '今日已签过到！',
									icon: 'none'
								})
							}
						}
					});
				} else {
					this.$common.goNavPage('/pages/login/weixinlogin');
				}
			},
			onGetUserLogin() {
				this.$httpost('/Login/isLogin', {}).then(res => {
					// console.log('isLogin', res)
					if (res.code == 200) {
						this.LoginInfo = res.data.LoginInfo
						if (this.LoginInfo.UserID > 0) {
							this.isLogin = true
						} else {
							this.isLogin = false
						}
					}
				});
			},
			goMakeMoka() {
				if (uni.getStorageSync("isLogin")) {
					this.$common.goNavPage('/moka/pages/makeMoka')
				} else {
					uni.navigateTo({
						url: '/pages/login/weixinlogin'
					})
					return false;
				}
			},
			goLogin() {
				uni.navigateTo({
					url: '/pages/login/weixinlogin'
				})
			},
			gotoMsgPage(MsgGroupID) {

				// console.log('this.isLogin', uni.getStorageSync("isLogin"))

				if (uni.getStorageSync("isLogin")) {

				} else {
					uni.navigateTo({
						url: '/pages/login/weixinlogin'
					})
					return false;
				}

				// if (this.isLogin == false) {
				// 	this.goLogin()
				// 	return false;
				// }

				// console.log(MsgGroupID);

				if (MsgGroupID == 3) {
					if (this.LoginInfo.UserLevelID !== 2) {
						if (this.LoginInfo.BeautifulWomen == 0) {
							this.isVipCheck = true
							return false;
						}
					}
				}

				let _that = this;
				this.$httpost('/Message/checkGroupAuth', {
					MsgGroupID: MsgGroupID
				}).then(res => {
					// console.log('checkGroupAuth', res);
					if (res.code == 200) {
						if (res.data.GroupMember !== null) {
							uni.navigateTo({
								url: '/messagePages/pages/msgpage?MsgGroupID=' + MsgGroupID
							})
						} else {
							uni.showModal({
								content: '您还没有加入会话群组，\r\n是否加入？',
								success: (ures) => {
									if (ures.confirm) {
										// console.log('执行加入')
										_that.JoinGroup(MsgGroupID);
									} else if (ures.cancel) {
										// console.log('不加入')
									}
								}
							})
						}
					}
				});
			},
			HandleCheckVip(e) {
				// console.log(e)

				if (e.index == 0) {
					this.$common.goNavPage('/pages/index/advert/advert?adid=1')
				} else {
					uni.navigateTo({
						url: '/myPages/pages/openVip'
					})
				}
			},
			onCancel() {
				this.isVipCheck = false
			},
			JoinGroup(MsgGroupID) {
				this.$httpost('/Message/joinGroup', {
					MsgGroupID: MsgGroupID
				}).then(res => {
					// console.log('joinGroup', res);
					if (res.code == 200) {
						uni.navigateTo({
							url: '/messagePages/pages/msgpage?MsgGroupID=' + MsgGroupID
						})
					}
				});
			},
			gotoYuedan() {
				this.switchTab(1)
			},
			//调用此方法显示抽屉
			showDrawer(type) {
				this.$refs.showRight.open();
			},
			closeDrawer(type) {
				this.$refs.showRight.close();
			},
			selectCityBtn() {
				uni.redirectTo({
					url: '/pages/index/selectCity'
				});
				// this.$common.goNavPage('/pages/index/selectCity')
			},
			getLocation() {
				var that = this;
				// getFuzzyLocation
				uni.getFuzzyLocation({
					// type: 'wgs84',
					success: (res) => {
						const latitude = res.latitude
						const longitude = res.longitude
						const speed = res.speed
						const accuracy = res.accuracy
						console.log('getFuzzyLocation', res) //将获取到的经纬度信息输出到控制台以便检查
						uni.showToast({
							title: '获取到您的位置！',
							icon: 'none'
						})
						that.setLocationData({ //将获取到的经度、纬度数值分别赋值给本地变量
							latitude: res.latitude,
							longitude: res.longitude
						})
					},
					fail: (err) => {
						uni.showModal({
							title: '位置',
							content: '未获取到您的位置，请手动选选择!',
							showCancel: false,
							confirmText: '选择',
							success: res => {
								if (res.confirm) {
									uni.navigateTo({
										url: '/pages/index/selectCity'
									})
								}
							}
						})
						// console.log("走到这里了没 ？",err)
					}
				})
			},
			setLocationData(addJson) {
				console.log('setLocationData', addJson);
				uni.showToast({
					title: '正在获取您所在的城市！',
					icon: 'none'
				})
				// regeo
				uni.request({
					url: 'https://restapi.amap.com/v3/geocode/regeo',
					data: {
						key: '4b984fdef9356e66e5d70e0f3e45730c',
						location: addJson.longitude + ',' + addJson.latitude
					},
					success: res => {
						console.log('返回用户地理位置', res);
						uni.showToast({
							title: '已获取您所在的城市！',
							icon: 'none'
						})

						let MyCity;

						this.CityList.forEach(function(item, index) {
							item.data.forEach(function(itm, idx) {
								if (itm.text == res.data.regeocode.addressComponent.city) {
									MyCity = itm;
								}
							})
						})

						// console.log('MyCity', MyCity)
						uni.setStorageSync("MyCity", MyCity);

						this.MyCity = uni.getStorageSync("MyCity")
						this.onGetList(0, 0);
					},
					fail(err) {
						uni.showToast({
							title: '未成功获取所在地区，请手动选择！',
							icon: 'none'
						})
					}
				})
			},
			changeTabs(e) {
				// console.log('oneIndex', e)
				// 清空筛选数据
				this.SearchParams = {};
				this.isChangeTab = false;
				this.page = 1;
				uni.setStorageSync('page', 1)
				this.switchTab(e.index)
			},
			tabChange(e) {
				// console.log(e)
				uni.setStorageSync('page', 1)
				this.isChangeTab = false;
				if (e.detail.source == 'touch') {
					let index = e.target.current || e.detail.current;
					this.switchTab(index);
				}
			},
			switchTab(index) {
				if (index == 0) {
					this.AsubTabIndex = 0;
					this.isHome = 0;
				}
				if (index == 1) {
					this.BsubTabIndex = 0;
					this.isHome = 1;
				}
				if (index == 2) {
					this.CsubTabIndex = 0;
					this.isHome = 1;
				}
				if (this.tabIndex === index) return;
				this.tabIndex = index;
			},
			changeSubTab(e, subIndex) {
				this.page = 1;
				uni.setStorageSync('page', 1)
				// 清空筛选数据
				this.SearchParams = {};
				// console.log('SubTab', e)
				if (subIndex == 'A') {
					this.AsubTabIndex = e.index;
					this.loadNoticeDataOne(e.index);
				}
				if (subIndex == 'B') {
					this.BsubTabIndex = e.index;
					this.loadResOrderDataOne(e.index);
				}
				if (subIndex == 'C') {
					this.isChangeTab = true;
					this.CsubTabIndex = e.index;
					this.loadWorksDataOne(e.index);
				}
			},
			loadIndexAd(index) {
				this.$httpost('/Home/loadIndexAd', {
					AdClassID: 1
				}).then(res => {
					if (res.code == 200) {
						this.AdList = res.data.AdList;
					}
				});
			},
			loadNoticeData(index, SearchParams) {
				let cityCode = null;

				if (Object.keys(SearchParams).length != 0) {
					cityCode = SearchParams.cityCode && Array.isArray(SearchParams.cityCode) ? SearchParams.cityCode[1] :
						SearchParams.cityCode;
					console.log(cityCode, 'cityCodecityCodecityCode1');
				} else {
					if (this.AsubTabIndex == 2) {
						cityCode = this.MyCity.subText
					} else {
						cityCode = 100000
					}
					console.log(cityCode, 'cityCodecityCodecityCode2');
				}


				this.more = 'loading';
				this.$httpost('/Home/loadNoticeData', {
					SearchRoleID: SearchParams && SearchParams.roleID ? SearchParams.roleID :
					'', // 为空的情况下渲染全部  roleID 角色ID
					City: cityCode, // 如果有筛选地址用筛选地址，没有用定位地址
					indexType: this.AsubTabIndex,
					page: this.page
				}).then(res => {
					if (res.code == 200) {
						if (index === 0) {
							if (this.NoticeListA.length != 0) {
								this.NoticeListA = [...this.NoticeListA, ...res.data.NoticeList];
								if (res.data.NoticeList.length == 0) this.more = 'onMore';
							} else {
								this.NoticeListA = res.data.NoticeList;
							}
						}

						if (index === 1) {
							if (this.NoticeListB.length != 0) {
								this.NoticeListB = [...this.NoticeListB, ...res.data.NoticeList];
								if (res.data.NoticeList.length == 0) this.more = 'onMore';
							} else {
								this.NoticeListB = res.data.NoticeList;
							}

						}
						if (index === 2) {
							if (this.NoticeListC.length != 0) {
								this.NoticeListC = [...this.NoticeListC, ...res.data.NoticeList];
								if (res.data.NoticeList.length == 0) this.more = 'onMore';
							} else {
								this.NoticeListC = res.data.NoticeList;
							}
						}

					}

				});
			},
			loadResOrderData(index, SearchParams) {
				let cityCode = null;

				if (Object.keys(SearchParams).length != 0) {
					cityCode = SearchParams.cityCode && Array.isArray(SearchParams.cityCode) ? SearchParams.cityCode[1] :
						SearchParams.cityCode;
					console.log(cityCode, 'cityCodecityCodecityCode1');
				} else {
					if (this.BsubTabIndex == 2) {
						cityCode = this.MyCity.subText
					} else {
						cityCode = 100000
					}
					console.log(cityCode, 'cityCodecityCodecityCode2');
				}

				let options = {
					SearchRoleID: SearchParams && SearchParams.reservationOrderObj ? SearchParams.reservationOrderObj :
						'', // 约单对象ID
					City: cityCode, // 地址
					page: this.page,
					indexType: this.BsubTabIndex,
					SearchPriceType: SearchParams && SearchParams.SearchPriceType ? SearchParams.SearchPriceType :
					'', // 收费模式
					SearchSex: SearchParams && SearchParams.searchSex ? SearchParams.searchSex : '' // 性别
				}

				this.more = 'loading';
				this.$httpost('/Home/loadResOrderData', options).then(res => {
					if (res.code == 200) {
						if (index === 0) {
							if (this.ReservationOrderListA.length != 0) {
								this.ReservationOrderListA = [...this.ReservationOrderListA, ...res.data
									.ReservationOrderList
								];
								if (res.data.ReservationOrderList.length == 0) this.more = 'onMore';
							} else {
								this.ReservationOrderListA = res.data.ReservationOrderList;
							}
						}
						if (index === 1) {
							if (this.ReservationOrderListB.length != 0) {
								this.ReservationOrderListB = [...this.ReservationOrderListB, ...res.data
									.ReservationOrderList
								];
								if (res.data.ReservationOrderList.length == 0) this.more = 'onMore';
							} else {
								this.ReservationOrderListB = res.data.ReservationOrderList;
							}
						}
						if (index === 2) {
							if (this.ReservationOrderListC.length != 0) {
								this.ReservationOrderListC = [...this.ReservationOrderListC, ...res.data
									.ReservationOrderList
								];
								if (res.data.ReservationOrderList.length == 0) this.more = 'onMore';
							} else {
								this.ReservationOrderListC = res.data.ReservationOrderList;
							}
						}
					}
				});
			},

			loadWorksData(index, SearchParams) {
				let cityCode = null;

				if (Object.keys(SearchParams).length != 0) {
					cityCode = SearchParams.cityCode && Array.isArray(SearchParams.cityCode) ? SearchParams.cityCode[1] :
						SearchParams.cityCode;
					console.log(cityCode, 'cityCodecityCodecityCode1');
				} else {
					if (this.CsubTabIndex == 2) {
						cityCode = this.MyCity.subText
					} else {
						cityCode = 100000
					}
					console.log(cityCode, 'cityCodecityCodecityCode2');
				}

				let options = {
					roleID: SearchParams && SearchParams.roleID ? SearchParams.roleID : '', // 发布人ID
					searchSex: SearchParams && SearchParams.searchSex ? SearchParams.searchSex : -1, // 性别
					City: cityCode, // 地址
					indexType: this.CsubTabIndex,
					page: this.page
				}

				this.$httpost('/Home/loadWorksData', options).then(res => {
					// console.log('indexData', res);
					if (res.code == 200) {
						this.oneRendering = false;
						if (index === 0) {
							if (this.WorksListA.length != 0) {
								this.WorksListA = [...this.WorksListA, ...res.data.WorksList];
								if (res.data.WorksList.length == 0) this.more = 'onMore';
							} else {
								this.WorksListA = res.data.WorksList;
							}
						}

						if (index === 1) {
							if (this.WorksListB.length != 0) {
								this.WorksListB = [...this.WorksListB, ...res.data.WorksList];
								if (res.data.WorksList.length == 0) this.more = 'onMore';
							} else {
								this.WorksListB = res.data.WorksList;
							}
						}
						if (index === 2) {
							if (this.WorksListC.length != 0) {
								this.WorksListC = [...this.WorksListC, ...res.data.WorksList];
								if (res.data.WorksList.length == 0) this.more = 'onMore';
							} else {
								this.WorksListC = res.data.WorksList;
							}
						}
						// console.log('this.WorksListA', this.WorksListA)
					}
				});
			},
			// 第一页通告数据
			loadNoticeDataOne(index) {
				let cityCode = null;
				if (this.AsubTabIndex == 2) {
					cityCode = this.MyCity.subText
				} else {
					cityCode = 100000
				}
				this.$httpost('/Home/loadNoticeData', {
					City: cityCode,
					indexType: this.AsubTabIndex,
					page: 1
				}).then(res => {
					// console.log('indexData', res);
					if (res.code == 200) {
						// console.log(index,'index')
						if (index == 0) this.NoticeListA = res.data.NoticeList;
						if (index == 1) this.NoticeListB = res.data.NoticeList;
						if (index == 2) this.NoticeListC = res.data.NoticeList;
						setTimeout(() => {
							// 关闭上拉刷新
							this.isRefreshList = false;
						}, 1000)

					}
				});
			},

			// 第一页约单数据
			loadResOrderDataOne(index) {
				let cityCode = null;
				if (this.BsubTabIndex == 2) {
					cityCode = this.MyCity.subText
				} else {
					cityCode = 100000
				}
				this.$httpost('/Home/loadResOrderData', {
					City: cityCode,
					indexType: this.BsubTabIndex,
					page: 1
				}).then(res => {
					// console.log('indexData', res);
					if (res.code == 200) {
						// console.log(index,'index')
						if (index == 0) this.ReservationOrderListA = res.data.ReservationOrderList;
						if (index == 1) this.ReservationOrderListB = res.data.ReservationOrderList;
						if (index == 2) this.ReservationOrderListC = res.data.ReservationOrderList;

						setTimeout(() => {
							// 关闭上拉刷新
							this.isRefreshList = false;
						}, 1000)
					}
				});
			},
			// 第一页作品数据
			loadWorksDataOne(index) {
				let cityCode = null;
				if (this.CsubTabIndex == 2) {
					cityCode = this.MyCity.subText
				} else {
					cityCode = 100000
				}
				this.$httpost('/Home/loadWorksData', {
					City: cityCode,
					indexType: this.CsubTabIndex,
					page: 1
				}).then(res => {
					// console.log('indexData', res);
					if (res.code == 200) {
						// console.log(index,'index')
						if (index == 0) this.WorksListA = res.data.WorksList;
						if (index == 1) this.WorksListB = res.data.WorksList;
						if (index == 2) this.WorksListC = res.data.WorksList;

						this.oneRendering = true;

						setTimeout(() => {
							// 关闭上拉刷新
							this.isRefreshList = false;
						}, 1000)
					}
				});
			},
			openSearch(type) {
				this.$refs.searchPopup.openSearch(type);
			},
			gotoAdUrl(item) {
				if (item.AdUrl !== null) {
					this.$common.goNavPage(item.AdUrl);
				} else {
					this.$common.goNavPage('/pages/index/advert/advert?adid=' + item.AdID);
				}
			},
			onGetList(tabIndex, subTabIndex) {
				this.$httpost('/Home/index', {
					indexType: 0,
					page: 1,
					City: 100000,
					AdClassID: 1
				}).then(res => {
					// console.log('indexData', res);
					if (res.code == 200) {
						this.AdList = res.data.AdList;
						this.Labels = res.data.Labels;

						// 通告
						this.NoticeListA = res.data.NoticeList;

						// 约单
						this.ReservationOrderListA = res.data.ReservationOrderList;

						// 作品
						this.WorksListA = res.data.WorksList;
						// 作品第一次渲染
						this.oneRendering = true;

						this.isSignin = res.data.isSignin;
					}

				});
			}
		},
	}
</script>

<style lang="scss" scoped>
	.status_bar {
		height: 90rpx;
		background-color: #FFF;
	}

	.indexTab {
		display: flex;
		background-color: #FFF;
		padding: 0rpx;
		border-bottom: 1rpx solid #f0f0f0;
		align-items: center;
	}

	.citySelect {
		width: 160rpx;
		font-size: 28rpx;
		text-align: center;
	}

	.index_menu {
		width: 400rpx;
	}

	.indexfTab {
		padding: 20rpx;
		background-color: #FFF;
		border-bottom: 1rpx solid #f0f0f0
	}

	.indexfTab_left {
		width: 360rpx
	}

	.signinBtn {
		width: 25rpx;
		height: 25rpx;

		border: 2rpx solid #333;
		border-radius: 25rpx;
		padding: 6rpx;
		text-align: center;
		line-height: 25rpx;
		font-size: 22rpx;
		// margin:25rpx;
	}

	.indexAdBox {
		margin: auto;
		margin-top: 20rpx;
		width: 96vw;
		height: 200rpx;
		border-radius: 20rpx;
	}

	.fui-banner__item {
		width: 100%;
		height: 200rpx;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 34rpx;
		border-radius: 20rpx;
		font-weight: 600;
	}

	.fui-banner__wrap {
		height: 200rpx;
		border-radius: 20rpx;
	}

	.swiper {
		height: 90vh;
	}

	.scroll {
		height: 90vh;
	}

	.indexBoxs {
		width: 100vw;
	}

	.noneInfos {
		text-align: center;
		padding: 100rpx;
		color: #999
	}

	.fui-title {
		font-size: 32rpx;
		padding-top: 24rpx;
	}

	.fui-descr {
		font-size: 24rpx;
		color: #B2B2B2;
		padding-top: 12rpx;
		padding-bottom: 48rpx;
	}

	.fui-icon__close {
		position: absolute;
		right: 24rpx;
		top: 20rpx;
	}

	.SigninPop {
		width: 80vw;
		height: 600rpx;
		background: #FFF;
		border-radius: 20rpx;
	}

	.SigninPopBox {
		height: 300rpx;
		padding-top: 100rpx;
		background-color: #FFFFCC;
		text-align: center;
		border-radius: 20rpx;
	}

	.SigninAddCoin {
		width: 180rpx;
		margin: auto;
		display: flex;
		margin-top: 30rpx
	}

	.InviteBtn {
		background-color: #FFDD00;
		width: 90%;
		height: 70rpx;
		line-height: 70rpx;
		border-radius: 30rpx;
	}
</style>